#include <iostream>
using namespace std;
int main()
{
    int n,money,i,j,a[120],dp[250][120],te,c,d;
    cin>>n;
    while (n--)
    {
        cin>>money;
        for (i=1;i<=money/150;i++)a[i]=3;
        for (j=1;j<=money/200;j++)a[j+i-1]=4;
        te=i+j-2;
        for (i=1;i<=money/50;i++)dp[i][0]=0;
        for (i=1;i<=money/50;i++)
            for (j=1;j<=te;j++)
            {
                c=dp[i][j-1];
                if (i>=a[j])
                {
                    d=dp[i-a[j]][j-1]+a[j];
                    if (d>c)c=d;
                }
                dp[i][j]=c;
            }
        cout<<money-dp[i-1][j-1]*50<<endl;
    }
    return 0;
}